/*
 * @Description:
 * @Author: Wang Su
 * @Date: 2023-09-16 23:31:37
 * @LastEditors: Wang Su
 * @LastEditTime: 2024-02-19 15:02:09
 */
const Koa = require("koa");
const cors = require("koa-cors");
const bodyParser = require("koa-bodyparser");
const logger = require("koa-logger");
const jsonerror = require("koa-json-error");
const parameter = require("koa-parameter");
const chartsRouter = require("./routers/chartsRouter.js");
const app = new Koa();
//处理跨域问题中间件
app.use(cors());
//处理错误中间件
app.use(jsonerror());
//处理post参数解析中间件
app.use(
  bodyParser({
    enableTypes: ["json", "form", "text"],
  })
);
app.use(parameter(app));
// 使用日志中间件
app.use(logger());

//路由中间件
app.use(chartsRouter.routes()).use(chartsRouter.allowedMethods());

const port = 19312;
app.listen(port, () => {
  console.log(`19312端口服务启用`);
});
